模块
export default vs export
- export default 只能出现一次,export not
- export default ,xx 可以是{},function(){},and others
- export ,xx可以是{}, const str = xx等形式
export
* export 字符串
1 2
| # demo.js export default 'hello world'
|
* export default {}
1 2 3 4
| #demo.js export default { hello:'hello', }
|
* export {}
1 2 3 4 5 6
| const hello = 'hello' export { hello, } #or export const hello = 'hello'
|
* import 字符串
1 2
| # foo = 'hello world' import foo from demo.js
|
* import from default
1 2 3 4
| # foo = { hello:'hello', } import foo from demo.js
|
* import {}
1 2
| # hello = 'hello' import { hello } from demo.js
|